/* 地区 */
function J_tab() {
    let tab = document.querySelectorAll('.tab');
    let J_blk = document.querySelectorAll('.J_blk_ABCDE');
    tab.forEach((item, index) => {
        item.onmouseover = () => {
            for (var i = 0; i < tab.length; i++) {
                tab[i].classList.remove('j_tab');
                J_blk[i].style.display = 'none';
            }
            item.classList.add('j_tab')
            J_blk[index].style.display = 'block';
        }
    })
}
J_tab()

/* 导航粘性定位 */
onscroll = function () {
    let center = document.querySelector('.centent');
    let scrTop = document.documentElement.scrollTop;
    let cenTop = center.offsetTop;
    if (scrTop >= cenTop) {
        center.style.borderBottom = '1px solid #000';
    } else {
        center.style.borderBottom = 'none';

    }
}


/* 展示右侧 */
function j_NavBg() {
    let j_li = document.querySelectorAll('.j_Li');
    let j_NavBg = document.querySelector('.j_NavBg');
    let cat_popup = document.querySelectorAll('.cat_popup');
    let cat_bd = document.querySelector('.cat_bd')
    j_li.forEach((item, index) => {
        item.addEventListener('mouseover', () => {
            let itTop = item.offsetTop;
            let cat_popupTop = cat_popup[index].offsetTop;
            j_NavBg.style.visibility = 'visible';
            j_NavBg.style.top = itTop + 'px';
            if (cat_popupTop <= 146) {
                cat_popup[index].style.display = 'block';
                cat_popup[index].style.top = itTop + 'px';
            } else {
                cat_popup[index].style.top = '146px';
            }
        })
        item.onmouseout = () => {
            cat_popup[index].style.display = 'none';
            j_NavBg.style.visibility = 'hidden';

        }
    })
}
j_NavBg()

    function zhanshi() {
        AG("/goods/category").then((resData) => {
            let Jli = document.querySelectorAll(".j_Li h3 a");
           
            console.log(resData.data);
            let types = resData.data.list.reverse();
            types.forEach((item, i) => {
                Jli[i].innerText=item;
                console.log(item);
                Jli[i].href=`list.html?type=${item}`;
                // html += `<li><a href="list.html?type=${item}">${item}</a></li>`;
            });
            // oUl.innerHTML = html;
        });
    }
    zhanshi()